package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author げっしょく
 * @date 2021/9/13
 */

@Component
@Aspect
public class AopAdivce {


    @Pointcut("execution(* com.itheima.dao.AccountDao.find*())")
    public void pf() {
    }


    @Around("pf()")
    public void method(ProceedingJoinPoint pjp) throws Throwable {
        Signature signature = pjp.getSignature();
        String declaringTypeName = signature.getDeclaringTypeName();
        String name = signature.getName();

        long l = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            Object proceed = pjp.proceed();
        }
        long l1 = System.currentTimeMillis();

        System.out.println(declaringTypeName + name + "的万次执行时间是：" + (l1 - l));

    }

}
